Skip to content

Auto-generate ConfigurationSchema.json for JSON IntelliSense#10139

Merged
JoshLove-msft merged 25 commits intomainfrom
copilot/add-auto-generate-configuration-schema-json
Mar 31, 2026
Merged

Auto-generate ConfigurationSchema.json for JSON IntelliSense#10139
JoshLove-msft merged 25 commits intomainfrom
copilot/add-auto-generate-configuration-schema-json

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 25, 2026

  • Add WriteAdditionalFiles() virtual method to CodeModelGenerator
  • Create ConfigurationSchemaGenerator class in Microsoft.TypeSpec.Generator.ClientModel
  • Override WriteAdditionalFiles() in ScmCodeModelGenerator to invoke schema generation
  • Hook into CSharpGen.ExecuteAsync() to write additional output files
  • Add 19 unit tests for ConfigurationSchemaGenerator (all passing)
  • Verify all existing tests still pass
  • Code review feedback: Remove Azure-specific logic from base emitter
  • Code review feedback: Delete chronus changelog file
  • Run regeneration to generate ConfigurationSchema.json for test projects
  • Common definitions (credential, options) are inherited from the System.ClientModel base schema and referenced via $ref — not duplicated locally
  • Add local definitions for additional non-base types (e.g., enums, models used as custom option properties) referenced via $ref
  • Model options type inheritance: each client's options type is a named local definition that extends the base options via allOf (matching the Azure emitter pattern from azure-sdk-for-net#57548)
  • Re-run generation to update all ConfigurationSchema.json files
  • Update Check-GitChanges.ps1 to also detect new untracked files so the CI regen check catches newly generated files
  • Add test cases for options types with additional properties (string, integer, and multiple mixed types)
  • Add test case and support for options properties that contain model definitions (with properties exposed in local definitions)
  • Add test case for model type used as a constructor parameter (appears as top-level client property with $ref to local definition)
  • Verify ConfigurationSchema.json works end-to-end via local pack and JSON Schema draft-07 meta-validation
  • Use m is ModelProvider instead of !(m is EnumProvider) for precise type checking
  • Add null check for Path.GetDirectoryName result in WriteAdditionalFiles
  • Add TestData golden file validation for 3 representative tests
  • Fix CI: scope untracked file check to generator/ directory to avoid false positive on README.md
  • Remove $schema line from generated ConfigurationSchema.json output (not needed since the consuming tool already knows the schema version)
  • Update System.ClientModel dependency to 1.10.0 for both the generator itself and generated project scaffolding

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Add schema generation for appsettings.json IntelliSense when a client
library has ClientSettings. The schema includes well-known client names
under 'Clients' (SCM) or 'AzureClients' (Azure) sections, with $ref to
shared credential/options definitions and allOf for client-specific
option extensions.

Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/555ac5bb-bd9c-4d73-90ca-f2922cf55fa5
@microsoft-github-policy-service microsoft-github-policy-service bot added the emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp label Mar 25, 2026
Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/555ac5bb-bd9c-4d73-90ca-f2922cf55fa5
Copilot AI changed the title [WIP] Add auto-generate ConfigurationSchema.json for JSON IntelliSense Auto-generate ConfigurationSchema.json for JSON IntelliSense Mar 25, 2026
Copilot AI requested a review from JoshLove-msft March 25, 2026 19:32
…rator

The base emitter should not contain Azure-specific code. Removed the
namespace-based Azure detection and made Generate() always use "Clients"
and "options" as defaults, with parameters allowing overrides by
derived emitters.

Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/78f8c1a0-1d00-4e19-89d1-e9090dc2aeab
Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/7703f03f-8937-43a3-b716-e0e5f8090658
@JoshLove-msft
Copy link
Copy Markdown
Contributor

@copilot why didn't the regen show a diff since we don't have a ConfigurationSchema.json checked in for the Test Project?

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 27, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/http-client-csharp@10139

commit: 0a2c3bd

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 27, 2026

@copilot why didn't the regen show a diff since we don't have a ConfigurationSchema.json checked in for the Test Project?

I hadn't run Generate.ps1 after adding the feature. Running it now generated 72 schema/ConfigurationSchema.json files across all test projects (Sample-TypeSpec + Spector). Committed in 2c0a31e.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • telemetry.astro.build
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/typespec/typespec/website/node_modules/.bin/../astro/bin/astro.mjs build node s/.b�� tput-dir ../../w--llmstxt . .2_tmp_4499_0/no../../website/src/content/docs/docs/emitters/openapi3/reference --import @typespec/librar/home/REDACTED/work/typespec/typespec/packages/http-specs/node_modules�� --no-emit node /nod�� gen-extern-signature sh _modules/.bin/sh node scripts/buinode l/reference n/sh sh (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@JoshLove-msft
Copy link
Copy Markdown
Contributor

@copilot why didn't the regen show a diff since we don't have a ConfigurationSchema.json checked in for the Test Project?

I hadn't run Generate.ps1 after adding the feature. Running it now generated 72 schema/ConfigurationSchema.json files across all test projects (Sample-TypeSpec + Spector). Committed in 2c0a31e.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

But why didn't the Regen check step fail on the diff then?

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 27, 2026

@copilot why didn't the regen show a diff since we don't have a ConfigurationSchema.json checked in for the Test Project?

I hadn't run Generate.ps1 after adding the featur...

Check-GitChanges.ps1 uses git diff (line 18), which only detects modifications to tracked files. Since the ConfigurationSchema.json files were brand new (untracked), they were invisible to the diff check. The script would need to also check for untracked files (e.g., via git status --porcelain) to catch newly generated files that aren't yet checked in.

Use ReplaceLineEndings to ensure consistent LF line endings across
platforms and append trailing newline to match prettier expectations.
Regenerated all ConfigurationSchema.json files.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@JoshLove-msft
Copy link
Copy Markdown
Contributor

@copilot CI is somehow failing on the git diff check on linux:

git -c core.safecrlf=false diff --ignore-space-at-eol --exit-code -- ":(exclude)/mnt/vss/_work/1/s/packages/http-client-csharp/package.json" ":(exclude)/mnt/vss/_work/1/s/packages/http-client-csharp/package-lock.json"
Command completed (00:00:02.5868706)

git ls-files --others --exclude-standard -- /mnt/vss/_work/1/s/packages/http-client-csharp
Command completed (00:00:00.0424453)

Untracked files detected:
README.md

…itive on README.md

Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/ff462cc0-505c-42c6-8027-7678fda9721b

Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 30, 2026

@copilot CI is somehow failing on the git diff check on linux:

git -c core.safecrlf=false diff --ignore-space-at-eol --exit-code -- ":(exclude)/mnt/vss/_work/1/s/packages/http-cli...

The untracked file check was scoped to the entire $packageRoot (packages/http-client-csharp), which picks up README.md at the package root. Scoped it to $packageRoot/generator instead, since that's where generated files (including ConfigurationSchema.json) live. Fixed in 50acbc4.

Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/26d73adf-067b-48e0-b996-36827bf3f448

Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
@JoshLove-msft
Copy link
Copy Markdown
Contributor

@copilot we need to update the version of SCM that we use as dependency to 1.10.0. Do this for both the generated dep and the dep of the generator itself.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 31, 2026

@copilot we need to update the version of SCM that we use as dependency to 1.10.0. Do this for both the generated dep and the dep of the generator itself.

Updated in 010e432:

  • Packages.Data.props: System.ClientModel → 1.10.0
  • NewProjectScaffolding.cs: generated dependency → 1.10.0
  • All 72 test project .csproj files: → 1.10.0
  • Also bumped transitive deps required by SCM 1.10.0: Microsoft.Extensions.Configuration.Abstractions → 10.0.3, System.Memory.Data → 10.0.3

JoshLove-msft and others added 3 commits March 30, 2026 18:34
- Generate .targets file alongside ConfigurationSchema.json in WriteAdditionalFiles
- Add PackItems support to CSharpProjectWriter for NuGet pack items
- Add pack items to NewProjectScaffolding for schema + .targets files
- Swap order: write additional files before project scaffolding so schema exists

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@JoshLove-msft JoshLove-msft added this pull request to the merge queue Mar 31, 2026
Merged via the queue into main with commit 9158cd1 Mar 31, 2026
37 checks passed
@JoshLove-msft JoshLove-msft deleted the copilot/add-auto-generate-configuration-schema-json branch March 31, 2026 19:25
"Options": {
"$ref": "#/definitions/sampleTypeSpecClientOptions"
}
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing "additionalProperties": true before the close of each client like Notebooks

msyyc pushed a commit that referenced this pull request Apr 1, 2026
- [x] Add `WriteAdditionalFiles()` virtual method to
`CodeModelGenerator`
- [x] Create `ConfigurationSchemaGenerator` class in
`Microsoft.TypeSpec.Generator.ClientModel`
- [x] Override `WriteAdditionalFiles()` in `ScmCodeModelGenerator` to
invoke schema generation
- [x] Hook into `CSharpGen.ExecuteAsync()` to write additional output
files
- [x] Add 19 unit tests for ConfigurationSchemaGenerator (all passing)
- [x] Verify all existing tests still pass
- [x] Code review feedback: Remove Azure-specific logic from base
emitter
- [x] Code review feedback: Delete chronus changelog file
- [x] Run regeneration to generate ConfigurationSchema.json for test
projects
- [x] Common definitions (`credential`, `options`) are inherited from
the [System.ClientModel base
schema](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/System.ClientModel/schema/ConfigurationSchema.json)
and referenced via `$ref` — not duplicated locally
- [x] Add local `definitions` for additional non-base types (e.g.,
enums, models used as custom option properties) referenced via `$ref`
- [x] Model options type inheritance: each client's options type is a
named local definition that extends the base `options` via `allOf`
(matching the Azure emitter pattern from azure-sdk-for-net#57548)
- [x] Re-run generation to update all ConfigurationSchema.json files
- [x] Update `Check-GitChanges.ps1` to also detect new untracked files
so the CI regen check catches newly generated files
- [x] Add test cases for options types with additional properties
(string, integer, and multiple mixed types)
- [x] Add test case and support for options properties that contain
model definitions (with properties exposed in local `definitions`)
- [x] Add test case for model type used as a constructor parameter
(appears as top-level client property with `$ref` to local definition)
- [x] Verify ConfigurationSchema.json works end-to-end via local pack
and JSON Schema draft-07 meta-validation
- [x] Use `m is ModelProvider` instead of `!(m is EnumProvider)` for
precise type checking
- [x] Add null check for `Path.GetDirectoryName` result in
`WriteAdditionalFiles`
- [x] Add TestData golden file validation for 3 representative tests
- [x] Fix CI: scope untracked file check to `generator/` directory to
avoid false positive on README.md
- [x] Remove `$schema` line from generated ConfigurationSchema.json
output (not needed since the consuming tool already knows the schema
version)
- [x] Update System.ClientModel dependency to 1.10.0 for both the
generator itself and generated project scaffolding

<!-- START COPILOT CODING AGENT TIPS -->
---

💡 You can make Copilot smarter by setting up custom instructions,
customizing its development environment and configuring Model Context
Protocol (MCP) servers. Learn more [Copilot coding agent
tips](https://gh.io/copilot-coding-agent-tips) in the docs.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
Co-authored-by: jolov <jolov@microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants